package com.team1.supervend.domain;

public class PaymentHandler {
	private CashPayment currentCashPayment;
	float totalPayment;
	public PaymentHandler(){
		//System.out.println("Creating Payment Handler");
	}
	
	public boolean makeCashPayment( Money cashTendered )
	{
		boolean validPayment;
		if (cashTendered.getMoney() > .01f){ 
			currentCashPayment = new CashPayment(cashTendered);
			validPayment = true;
		}
		else validPayment = false;
		ackPayment();
		totalPayment = totalPayment + cashTendered.getMoney();
		System.out.println("-------------------");
		System.out.format("Total Payments: $%.2f\n", totalPayment);
		System.out.println("-------------------");
		return validPayment;
		
	}
	
	public Money ackPayment(){
		Money balance;
		balance = currentCashPayment.getAmount();
		System.out.println("-------------------");
		System.out.format("money added: $%.2f\n", balance.getMoney());
		System.out.println("-------------------");
		return balance;
	}

}
